<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function method() {
        console.log(this.name);
      }
      method();
      function add(a, b, c, d) {
        console.log(a + b);
      }
      //apply()方法
      method.apply({ name: "张三" });
      add.apply({}, [1, 2]); //第二个参赛必须是数组
      //call()方法
      method.call({ name: "李四" });
      add.call({}, 3, 4, 5, 6); //第二个参赛 2~N
      //bind() 绑定
      var name = "王五";
      function test(a, b) {
        // console.log(this);
        console.log(this.name + a + b);
      }
      test(1, 2);

      let myF = test.bind({ name: "zhuba" }, "7", "8");
      myF();
    </script>
  </body>
</html>
